/**
 * amis v6.13.0
 * build time: 2025-08-12
 * Copyright 2018-2025 baidu
 */

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var _withBadge = require('amis-ui/lib/components/withBadge');
var _Link = require('amis-ui/lib/components/Link');
var tslib = require('tslib');
var React = require('react');
var amisCore = require('amis-core');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var _withBadge__default = /*#__PURE__*/_interopDefaultLegacy(_withBadge);
var _Link__default = /*#__PURE__*/_interopDefaultLegacy(_Link);
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);

var __react_jsx__ = require('react');
var _J$X_ = (__react_jsx__["default"] || __react_jsx__).createElement;
var _J$F_ = (__react_jsx__["default"] || __react_jsx__).Fragment;


;var LinkCmpt = /** @class */function (_super) {
  tslib.__extends(LinkCmpt, _super);
  function LinkCmpt() {
    return _super !== null && _super.apply(this, arguments) || this;
  }
  LinkCmpt.prototype.handleClick = function (e) {
    var _a = this.props,
      env = _a.env,
      href = _a.href,
      blank = _a.blank,
      body = _a.body;
    env === null || env === void 0 ? void 0 : env.tracker({
      eventType: 'url',
      // 需要和 action 里命名一致方便后续分析
      eventData: {
        url: href,
        blank: blank,
        label: body
      }
    }, this.props);
  };
  LinkCmpt.prototype.getHref = function () {};
  LinkCmpt.prototype.render = function () {
    var _a = this.props,
      className = _a.className,
      style = _a.style,
      body = _a.body,
      href = _a.href,
      cx = _a.classnames,
      blank = _a.blank,
      disabled = _a.disabled,
      htmlTarget = _a.htmlTarget,
      data = _a.data,
      render = _a.render,
      __ = _a.translate,
      title = _a.title,
      icon = _a.icon,
      rightIcon = _a.rightIcon;
    var value = (typeof href === 'string' && href ? amisCore.filter(href, data, '| raw') : undefined) || amisCore.getPropValue(this.props);
    return _J$X_(_Link__default["default"], {
      className: className,
      style: style,
      href: value,
      disabled: disabled,
      title: title,
      htmlTarget: htmlTarget || (blank ? '_blank' : '_self'),
      icon: icon,
      rightIcon: rightIcon,
      onClick: this.handleClick
    }, body ? render('body', body) : value || __('link'));
  };
  LinkCmpt.defaultProps = {
    blank: true,
    disabled: false,
    htmlTarget: ''
  };
  tslib.__decorate([amisCore.autobind, tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", [Object]), tslib.__metadata("design:returntype", void 0)], LinkCmpt.prototype, "handleClick", null);
  return LinkCmpt;
}(React__default["default"].Component);
var LinkFieldRenderer = /** @class */function (_super) {
  tslib.__extends(LinkFieldRenderer, _super);
  function LinkFieldRenderer() {
    return _super !== null && _super.apply(this, arguments) || this;
  }
  LinkFieldRenderer = tslib.__decorate([amisCore.Renderer({
    type: 'link'
  })
  // @ts-ignore 类型没搞定
  , _withBadge__default["default"]], LinkFieldRenderer);
  return LinkFieldRenderer;
}(LinkCmpt);

exports.LinkCmpt = LinkCmpt;
exports.LinkFieldRenderer = LinkFieldRenderer;
